package org.come.Jpanel;

import java.awt.*;

import javax.swing.*;

import org.come.Frame.TaobaoCourtMainJframe;
import org.come.model.Eshop;
import org.come.mouslisten.ShopingImgBorderMosulisten;
import org.come.until.CutButtonImage;

import com.tool.btn.ShopBuyBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
/**
 * @author 黄建彬
 * @date : 2017年12月13日 下午4:41:29
 * 
 *       用来设置在线商城物品小面板
 */


public class GoodsTJMinJpanel extends JPanel {
	private String name, // 商品名称
			value; // 商品价格
	private JLabel buyCount, goodsImg, labBorder;// 购买金额,物品图片,背景框
	private ShopBuyBtn buyBtn; // 购买按钮

	private ShopingImgBorderMosulisten borderMosulisten;

	@Override
    protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		if (name != null) {
			g.setFont(UIUtils.TEXT_FONTSC);
			g.setColor(UIUtils.COLOR_NAME6);
			g.drawString(name, 23, 208);
		}
		if (value != null){
		    g.setFont(UIUtils.TEXT_TIP1);
			g.setColor(UIUtils.COLOR_HIHT);
			g.drawString(value, 33, 235);
		}
	}


	public GoodsTJMinJpanel(Eshop eshop) {

			this.setLayout(null);
			this.setPreferredSize(new Dimension(802, 538));
			this.setOpaque(false);

			borderMosulisten = new ShopingImgBorderMosulisten(eshop);
			name = eshop.getEshopname();
			// if
			// (TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getTaobaoCourtCardJpanel()
			// .getShopOnlineJpanel().getShopType() == 11) {
			// value = eshop.getEshopprice() + "积分";
			// } else {
			// value = eshop.getEshopprice() + "仙玉";
			// }
			value = eshop.getEshopprice() + "";
			// 设置控件信息
			buyBtn = new ShopBuyBtn("inkImg/number/b8/goodskAJ1.png", 1, "", 1, eshop);
			buyBtn.setBounds(0, 180, 180, 66);

			labBorder = new JLabel();
			labBorder.setBounds(0, 0, 180, 180);
			labBorder.setOpaque(false);
			labBorder.setIcon(CutButtonImage.getImage("inkImg/number/b8/homebj.png", -1, -1));

			// 设置放置物品图片
			goodsImg = new JLabel();
			goodsImg.setBounds(30, 30, 120, 120);
			ImageIcon image = CutButtonImage.getImage("img/item/" + eshop.getEshopskin() + ".png", 120, 120);
			goodsImg.setIcon(image);
			goodsImg.addMouseListener(borderMosulisten);

			this.add(buyBtn);
			this.add(goodsImg);
			this.add(labBorder);


	}

	/** 清空数据 */
	public void clearView() {
		name = "";
		value ="";
		buyBtn.setBtn(0);
		buyBtn.setIcon(null);
		buyBtn.setText("");
		buyBtn.setEshop(null);
		goodsImg.setIcon(null);
		borderMosulisten.setEshop(null);
		labBorder.setIcon(null);
	}

	/** 获取物品数据展示在面板上 */
	public void addEshopMessage(Eshop eshop) {
			if (eshop == null) {
				return;
			}
			buyBtn.setEshop(eshop);
			buyBtn.setBtn(1);
			buyBtn.setText("");
			try {
				buyBtn.setIcons(CutButtonImage.cuts("inkImg/number/b8/goodskAJ1.png"));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			borderMosulisten.setEshop(eshop);
			if (TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getTaobaoCourtCardJpanel().getShopOnlineJpanel().getShopType() == 11) {
				value = eshop.getEshopprice() + "";
			} else {
				value = eshop.getEshopprice() + "";
			}
			// value = (eshop.getEshopprice() + "仙玉");
			name = eshop.getEshopname();
			labBorder.setIcon(CutButtonImage.getImage("inkImg/number/b8/homebj.png", -1, -1));
			goodsImg.setIcon(CutButtonImage.getImage("img/item/" + eshop.getEshopskin() + ".png", 120, 120));


	}




	public ShopBuyBtn getBuyBtn() {
		return buyBtn;
	}

	public void setBuyBtn(ShopBuyBtn buyBtn) {
		this.buyBtn = buyBtn;
	}

	public JLabel getBuyCount() {
		return buyCount;
	}

	public void setBuyCount(JLabel buyCount) {
		this.buyCount = buyCount;
	}

	public JLabel getGoodsImg() {
		return goodsImg;
	}

	public void setGoodsImg(JLabel goodsImg) {
		this.goodsImg = goodsImg;
	}

	public JLabel getLabBorder() {
		return labBorder;
	}

	public void setLabBorder(JLabel labBorder) {
		this.labBorder = labBorder;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public void setName(String name) {
		this.name = name;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public ShopingImgBorderMosulisten getBorderMosulisten() {
		return borderMosulisten;
	}

	public void setBorderMosulisten(ShopingImgBorderMosulisten borderMosulisten) {
		this.borderMosulisten = borderMosulisten;
	}

}
